#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
using namespace std;

class Date
{
public:
    friend ostream& operator<<(ostream& os, Date& d);

    Date(int year = 1, int month = 1, int day = 1)
        : _year(year)
        , _month(month)
        , _day(day)
    {}

    int getDay(int year, int month)
    {
        static int arr[] = { -1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };

        if (month == 2 && ((year % 4 == 0) && (year % 100 != 0) || (year % 400 == 0)))
            return 29;
        else
            return arr[month];
    }

    void trun_to_month()
    {
        for (int month = 1; month < 13; month++)
        {
            if (_day > getDay(_year, month))
                _day -= getDay(_year, month);
            else
            {
                _month = month;
                break;
            }
        }
    }

private:
    int _year;
    int _month;
    int _day;
};

ostream& operator<<(ostream& os, Date& d)
{
	if(d._month >= 10 && d._day >= 10)
		os << d._year << "-" << d._month << "-" << d._day;
	else if (d._month < 10 && d._day < 10)
		os << d._year << "-0" << d._month << "-0" << d._day;
	else if (d._month >= 10 && d._day < 10)
		os << d._year << "-" << d._month << "-0" << d._day;
	else if (d._month < 10 && d._day >= 10)
		os << d._year << "-0" << d._month << "-" << d._day;
	return os;
}

int main() {
    int year, day;
    while (cin >> year >> day) {
        Date d(year, 1, day);
        d.trun_to_month();
        cout << d << endl;
    }
}